window = global;

//导入算法包 安装指令：d://npm_install_package>npm install crypto-js
const cryptoJs = require('./npm_install_package/node_modules/crypto-js');
//导入jsencrypt就是一个基于rsa加解密的js库 安装指令：npm install jsencrypt
const jsEncrypt = require('./npm_install_package/node_modules/jsencrypt')

function b(A, e, t) {
    return e in A ? Object.defineProperty(A, e, {
        value: t,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : A[e] = t,
        A
}

function v(A, e) {
    var t = Object.keys(A);
    if (Object.getOwnPropertySymbols) {
        var n = Object.getOwnPropertySymbols(A);
        e && (n = n.filter((function (e) {
                return Object.getOwnPropertyDescriptor(A, e).enumerable
            }
        ))),
            t.push.apply(t, n)
    }
    return t
}

function m(A) {
    for (var e = 1; e < arguments.length; e++) {
        var t = null != arguments[e] ? arguments[e] : {};
        e % 2 ? v(Object(t), !0).forEach((function (e) {
                b(A, e, t[e])
            }
        )) : Object.getOwnPropertyDescriptors ? Object.defineProperties(A, Object.getOwnPropertyDescriptors(t)) : v(Object(t)).forEach((function (e) {
                Object.defineProperty(A, e, Object.getOwnPropertyDescriptor(t, e))
            }
        ))
    }
    return A
}

function w(A) {
    var e, t, n = "", r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", a = "=";
    for (e = 0; e + 3 <= A.length; e += 3)
        t = parseInt(A.substring(e, e + 3), 16),
        n += r.charAt(t >> 6) + r.charAt(63 & t);
    e + 1 == A.length ? (t = parseInt(A.substring(e, e + 1), 16),
    n += r.charAt(t << 2)) : e + 2 == A.length && (t = parseInt(A.substring(e, e + 2), 16),
    n += r.charAt(t >> 2) + r.charAt((3 & t) << 4));
    while ((3 & n.length) > 0)
        n += a;
    return n
}


// t = new d["a"]; 使用到了 webpack
t = new jsEncrypt();
console.log(t)
/** 此时 t值 与浏览器中的 t = new d["a"]; 一摸一样了；
 JSEncrypt {
  default_key_size: 1024,
  default_public_exponent: '010001',
  log: false,
  key: null
} */
t.encryptLong = function(A) {
    var e = this.getKey()
      , t = (e.n.bitLength() + 7 >> 3) - 11;
    try {
        var n = ""
          , r = "";
        if (A.length > t)
            return n = A.match(/.{1,50}/g),
            n.forEach((function(A) {
                var t = e.encrypt(A);
                r += t
            }
            )),
            w(r);
        var a = e.encrypt(A)
          , s = w(a);
        return s
    } catch (i) {
        return i
    }
}
var publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCcwFsgkyzH57iPgWMQR/42lN7akFgSZiZVlpg9erq6VlQKY7yY00GFsKVXDCj9InI+0/RPHNzyKtkMcVm7GhUa7q5mWqukBdnQV5yoUo2jN2bby+ivYhe66UyqcF+FAsc4pxFuwAKvrGXqUBlJff5pX/DdDd8Ux9W/1+qD1nrbCwIDAQAB';
r = publicKey;
t.setPublicKey(r);
e = {"inviteMethod":"","businessClassfication":"","mc":"","lx":"ZBGG","dwmc":"","pageIndex":1};
a = m(m({}, e), {}, {
    // sign: B()(JSON.stringify(e)),
    sign: cryptoJs.MD5(JSON.stringify(e)).toString(),
    timeStamp: +new Date
})
s = t.encryptLong(JSON.stringify(a));
console.log(s)

/**
 控制台：
 JSON.stringify(new d["a"])
 RSA算法是这种的
 {"default_key_size":1024,"default_public_exponent":"010001","log":false,"key":null}
 */